﻿@{
    ViewBag.Title = "signin";
}



<div class="container">

    <div class="row">

        <div class="col-md-14">

            <h2>signin</h2>
            <div id="result" style="color:red"></div>

            @*<form action="../Account/validateSignin" method="post">*@

            <form name="signinForm" method="post">
                <table border="1">
                    <tr>
                        <td>
                            Enter Username:
                        </td>

                        <td>
                            <input type="text" name="username" id="username" placeholder="Enter UserName" required />
                        </td>
                    </tr>

                    <tr>
                        <td>
                            Enter Password:
                        </td>

                        <td>
                            <input type="password" name="pwd" id="pwd" placeholder="Enter Password" required />
                        </td>
                    </tr>

                    <tr>
                        <td></td>

                        <td>
                            <input type="button" id="signin" name="signin" value="SignIn" />
                        </td>
                    </tr>

                </table>

            </form>
        </div>
    </div>
</div>
<script>

    $(document).ready(function () {

        $('#signin').click(function () {

            var username = $('#username').val();
            var pwd = $('#pwd').val();

            $.getJSON("validateSignin?u=" + username + "&p=" + pwd, function (data) {

                if (data == null) {
                    $('#result').text("Incorrect Username Or Password");

                    $('#username').val("");
                    $('#pwd').val("");
                    //return false;
                }
                else {

                    window.location = "../User/ProfilePage";
                    //return true;
                }
            });

        });
    });
</script>
